#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

int main()
{
    int fd;
    fd=open("file",O_WRONLY | O_CREAT | O_TRUNC,
                S_IWUSR | S_IRUSR | S_IWGRP | S_IROTH);
    if(fd == -1)/*错误*/
    printf("%s","打开文件错误");
    return 0;
}